package com.bjmashibing.system.OSFileIO.nio_demo;

import com.sun.xml.internal.ws.api.client.WSPortInfo;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class SocketDemo {

    public static void main(String[] args) throws IOException {
       demo1();
    }

    private static void demo1() throws IOException {
        ServerSocket serverSocket=new ServerSocket(8080);
        Socket socket=serverSocket.accept();
        InputStream inputStream = socket.getInputStream();
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        String str=null;
        while ((str=bufferedReader.readLine())!=null){
            if (str.equals("")){
                break;
            }
            System.out.println(str);
        }
    }
}
